import {getAllStaticData} from "@/api/system";

const system = {
    state: {
        staticData:[]
    },
    mutations: {
        setStaticData(state,info){
            state.staticData = info
        },

    },
    actions: {
        GetStaticData({commit}){
            return new Promise((resolve, reject) =>{
                getAllStaticData().then(res =>{
                    commit('setStaticData',res.data);
                    resolve(res)
                }).catch(err=>{
                    console.log(err)
                    reject(err)
                })
            })
        }
    },
    getters:{
        getStaticValue:(state)=>(paramKey)=>{
            for (let item of state.staticData){
                if (item.paramKey===paramKey){
                    return item.paramValue
                }
            }
            return ''
        }
    }
}

export default system

